<?php

class Webservice_IndexController extends Zend_Controller_Action {

    public function init() {
        /* Initialize action controller here */
    }

    public function indexAction() {
        // action body
    }

    public function getcategoryAction() {
        $this->getHelper('viewRenderer')->setNoRender(true);
        
        // init var
        $model = new Webservice_Model_Logic();
        $utilWs = new Webservice_Model_LogicHelper();
        
        $params = $this->_request->getParams();
        if(!array_key_exists('id', $params) || 
           !array_key_exists('limit', $params) ||
           !array_key_exists('from', $params)) {
            $utilWs->buildDataJSON(array('error' => 'Invalid Param'));
        } else {
            $result = $model->getCategoryList($aryCategory, $params);
            $aryResponse = array (
                'result' => $result,
                'data' => $aryCategory
            );
            $utilWs->buildDataJSON($aryResponse);
        }
    }
    
    public function getshopAction() {
        $this->getHelper('viewRenderer')->setNoRender(true);
        
        // init var
        $model = new Webservice_Model_Logic();
        $utilWs = new Webservice_Model_LogicHelper();
        
        $params = $this->_request->getParams();
        if(!array_key_exists('id', $params) || 
           !array_key_exists('limit', $params) ||
           !array_key_exists('from', $params)) {
            $utilWs->buildDataJSON(array('error' => 'Invalid Param'));
        } else {
            $result = $model->getShopList($aryShop, $params);
            $aryResponse = array (
                'result' => $result,
                'data' => $aryShop
            );
            $utilWs->buildDataJSON($aryResponse);
        }
    }
    
    public function getgoodAction() {
        $this->getHelper('viewRenderer')->setNoRender(true);
        
        // init var
        $model = new Webservice_Model_Logic();
        $utilWs = new Webservice_Model_LogicHelper();
        
        $params = $this->_request->getParams();
        if(!array_key_exists('id', $params) || 
           !array_key_exists('limit', $params) ||
           !array_key_exists('from', $params)) {
            $utilWs->buildDataJSON(array('error' => 'Invalid Param'));
        } else {
            $result = $model->getGoodList($aryGood, $params);
            $aryResponse = array (
                'result' => $result,
                'data' => $aryGood
            );
            $utilWs->buildDataJSON($aryResponse);
        }
    }
    
    public function searchshopAction() {
        $this->getHelper('viewRenderer')->setNoRender(true);
        // init var
        $model = new Webservice_Model_Logic();
        $utilWs = new Webservice_Model_LogicHelper();
        
        $params = $this->_request->getParams();
        if(!array_key_exists('keyword', $params) || 
           !array_key_exists('limit', $params) ||
           !array_key_exists('from', $params)) {
            $utilWs->buildDataJSON(array('error' => 'Invalid Param'));
        } else {
            $result = $model->searchShop($aryShop, $params);
            $aryResponse = array (
                'result' => $result,
                'data' => $aryShop
            );
            $utilWs->buildDataJSON($aryResponse);
        }
    }
    
    public function searchgoodAction() {
        $this->getHelper('viewRenderer')->setNoRender(true);
        
        // init var
        $model = new Webservice_Model_Logic();
        $utilWs = new Webservice_Model_LogicHelper();
        
        $params = $this->_request->getParams();
        if(!array_key_exists('keyword', $params) || 
           !array_key_exists('limit', $params) ||
           !array_key_exists('from', $params)) {
            $utilWs->buildDataJSON(array('error' => 'Invalid Param'));
        } else {
            $result = $model->searchGood($aryGood, $params);
            $aryResponse = array (
                'result' => $result,
                'data' => $aryGood
            );
            $utilWs->buildDataJSON($aryResponse);
        }
    }
}

